
 <template>
 	<el-dialog title="修改" visible :show-close="false" :modal-append-to-body="false" class="wrap" size="tiny">
 		<i class="el-icon-close close" @click="cancel"></i>
 		<el-form label-width="100px" class="form">
 			<el-form-item label="学生ID">
 				<el-input v-model="form.xsid" type="textarea" :rows="1" placeholder="请输入" class="select-block"></el-input>
 			</el-form-item>
 			<el-form-item label="单元id">
 				<el-input v-model="form.dyid" type="textarea" :rows="1" placeholder="请输入" class="select-block"></el-input>
 			</el-form-item>
 			<el-form-item label="试题id">
 				<el-input v-model="form.stid" type="textarea" :rows="1" placeholder="请输入" class="select-block"></el-input>
 			</el-form-item>
 			<el-form-item label="听说类型">
 				<el-input v-model="form.ydlx" type="textarea" :rows="1" placeholder="请输入" class="select-block"></el-input>
 			</el-form-item>
 			<el-form-item label="学生发音音频地址">
 				<el-input v-model="form.ypdz" type="textarea" :rows="1" placeholder="请输入" class="select-block"></el-input>
 			</el-form-item>
 			<el-form-item label="分数">
 				<el-input v-model="form.fs" type="textarea" :rows="1" placeholder="请输入" class="select-block"></el-input>
 			</el-form-item>
 			<el-form-item label="星数">
 				<el-input v-model="form.xs" type="textarea" :rows="1" placeholder="请输入" class="select-block"></el-input>
 			</el-form-item>
 			<el-form-item label="发音得分">
 				<el-input v-model="form.fydf" type="textarea" :rows="1" placeholder="请输入" class="select-block"></el-input>
 			</el-form-item>
 			<el-form-item label="流利度)">
 				<el-input v-model="form.lld" type="textarea" :rows="1" placeholder="请输入" class="select-block"></el-input>
 			</el-form-item>
 			<el-form-item label="完整度">
 				<el-input v-model="form.wzd" type="textarea" :rows="1" placeholder="请输入" class="select-block"></el-input>
 			</el-form-item>
 			<el-form-item label="错误单词">
 				<el-input v-model="form.cwdc" type="textarea" :rows="1" placeholder="请输入" class="select-block"></el-input>
 			</el-form-item>
 			<el-form-item label="备注">
 				<el-input v-model="form.inflag" type="textarea" :rows="1" placeholder="请输入" class="select-block"></el-input>
 			</el-form-item>
 		</el-form>
 		<el-button type="info" class="submit" @click="submit">修改</el-button>
 	</el-dialog>
 </template>
 <script type="text/javascript">
 	import qs from 'qs'
 	export default {
 		props: ['params'],
 		data() {
 			return {
 				form: {
 xsid :'',
 dyid :'',
 stid :'',
 ydlx :'',
 ypdz :'',
 fs :'',
 xs :'',
 fydf :'',
 lld :'',
 wzd :'',
 cwdc :'',
 inflag :'',
 					id:''
 				}
 			}
 		},
 		created() {
  		 this.form.id = this.params.row.id;
          this.loadinfo();
 		},
 		methods: {
 			loadinfo(){
 				var logininfo = JSON.parse(localStorage.logininfo);
              this.searchLoading = true;
             var params2 = qs.stringify({
                      xxid:logininfo.xxid,
 							 yhid:logininfo.id,
 							 id:this.form.id
               })
             //执行
                 this.axios.post(this.$store.state.api + 'xsstzy/info',  params2 )
                 .then(res => {
                 this.form=res.data.data
                  this.searchLoading = false;
                 }).catch(res => {
					 this.$message.warning("服务器异常");
 			 				this.$emit('close', { type: 'info', cancel: true });
				})
 				
 				
 				
// 				 var logininfo = JSON.parse(localStorage.logininfo) ;
// 				 this.axios.get(this.$store.state.api+'xsstzy/info',{
// 						 params:{
// 							 xxid:logininfo.xxid,
// 							 yhid:logininfo.id,
// 							 id:this.form.id
// 						 }
// 					}).then( res =>  {
// 							this.form=res.data.data
// 					 }).catch(res => {
// 						 this.$message.warning("服务器异常");
// 			 				this.$emit('close', { type: 'info', cancel: true });
// 					 })
 			},
 			 submit() {
 				//检测
 				this.$store.state.loading = true;
 				/*if(!this.form.id) {
 					this.$message.warning('请填写分类');
 					this.$store.state.loading = false;
 					return;
 				}*/
 				//装载数据
 				var logininfo = JSON.parse(localStorage.logininfo);
 				var params2 = qs.stringify({
 						id: this.form.id,
 						xsid: this.form.xsid,
 						dyid: this.form.dyid,
 						stid: this.form.stid,
 						ydlx: this.form.ydlx,
 						ypdz: this.form.ypdz,
 						fs: this.form.fs,
 						xs: this.form.xs,
 						fydf: this.form.fydf,
 						lld: this.form.lld,
 						wzd: this.form.wzd,
 						cwdc: this.form.cwdc,
 						inflag: this.form.inflag,
 						yhid: logininfo.id,
 						xxid: logininfo.xxid
 					})
 				//执行
 				    this.axios.post(this.$store.state.api + 'xsstzy/update',  params2 )
 						.then(res => {
 							if(res.data.code == 1) {
 								this.$emit('close', { type: 'edit', cancel: false });
 								this.$store.state.loading = false;
 							} else {
 								this.$emit('close', { type: 'edit', cancel: false });
 								this.$store.state.loading = false;
 							}
 						}).catch(res => {
 							this.$message.warning("服务器异常");
 							this.$store.state.loading = false;
 						})
 			},
 			cancel() {
 				this.$emit('close', { type: 'edit', cancel: true })
 			}
 		}
 	}
 </script>
 <style lang="less" scoped>
 	.wrap {
 		text-align: center;
 	}
 	.form {
 		text-align: left;
 	}
 	.input {
             width: 300px;
             display: inline-block;
         }
 	.select-block {
 		display: block;
 	}
 	.submit {
 		width: 120px;
 	}
 </style>
